home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / bbbbs85.lha / rexx / BBBBSdemon.baud < prev    next >
Text File  |  1994-11-11  |  4KB  |  110 lines

  1. /* $VER: BBBBSdemon.baud 8.0 (11.11.94)
  2.  
  3. USAGE: run rx BBBBSdemon.baud   ; run after BaudBandit is running
  4.  
  5. This program handles those cases where BBBBS might fail to properly
  6. log-off after a disconnect during transfer or message entry.
  7. (The classic case is a hangup during message entry, followed by
  8. numerous "RING"s... The BBS sees the RING and thinks the user is
  9. still entering text, so it doesn't close the buffer!)
  10.  
  11. Reboots after about 10 minutes (5 decreasing checks) if the user
  12. didn't logout (BBS_level~=''), and there is no carrier.
  13.  
  14. Does nothing the 1st time, then tries closing the buffer,
  15. and finally, on the third check, tries CTRL-C & ESC (nasty reset!).
  16.  
  17. If all this fails to reset the BBS, the program boot is
  18. run if is found in the C: directory.
  19.  
  20. */
  21.  
  22.  
  23. IF SHOW('P','BBBBS_DEMON') THEN EXIT
  24. CALL OPENPORT('BBBBS_DEMON')
  25. CR='0D'x
  26.  
  27. chances=1
  28. DO WHILE chances<7              /* 6 checks */
  29.   CALL DELAY(50*300%chances)    /* pauses get shorter with trouble */
  30.   p=GETPKT('BBBBS_DEMON')       /* ANY message means time to quit */
  31.   IF p~='0000 0000'x THEN
  32.     DO WHILE p~='0000 0000'x    /* empty the port */
  33.       DO
  34.         t=REPLY(p,0)
  35.         p=GETPKT('BBBBS_DEMON')
  36.       END
  37.       chances=7                 /* ... and quit */
  38.     END
  39.   ELSE IF GETCLIP('BBS_level')='' THEN
  40.     chances=1   /* inactive bbs */
  41.   ELSE IF ~SHOW('P','BBBBS') THEN
  42.     DO
  43.       IF GETCLIP('BBS_level')~='' THEN
  44.         DO
  45.           CALL SETCLIP('BBS_level') /* BBBBS has crashed? restart */
  46.           ADDRESS AREXX bbsRestart.rexx
  47.         END
  48.       chances=1   /* bbbbs not running */
  49.     END
  50.   ELSE
  51.     DO
  52.       ADDRESS BAUD
  53.       dcd
  54.       IF RC=0 THEN
  55.         DO
  56.           chances=chances+1                   /* no carrier, so... */
  57.           IF chances=2 THEN      /* tell "difficult" doors to quit */
  58.             DO
  59.               Send '\r/E\r'
  60.               CALL DELAY(150)
  61.               IF GETCLIP('BBS_level')='' THEN BREAK
  62.               Send '\rEXIT\r'
  63.               CALL DELAY(150)
  64.               IF GETCLIP('BBS_level')='' THEN BREAK
  65.               Send '\rQUIT\r'
  66.               CALL DELAY(150)
  67.               IF GETCLIP('BBS_level')='' THEN BREAK
  68.               Send '\rQ\r'
  69.               CALL DELAY(150)
  70.               IF GETCLIP('BBS_level')='' THEN BREAK
  71.               Send '\rOFF\r'
  72.               CALL DELAY(150)
  73.               IF GETCLIP('BBS_level')='' THEN BREAK
  74.               Send '\rBYE\r'
  75.             END
  76.           IF chances=3 THEN
  77.             DO
  78.               Send '\r/E\r'   /* be sure buffer is closed */
  79.               IF GETCLIP('BBS_level')~='' THEN
  80.                 DO
  81.                   CALL DELAY(100)
  82.                   Send '\ah'
  83.                 END
  84.             END
  85.           IF chances=4 THEN Send '\e'      /* ESCape to stop transfer */
  86.           IF chances=5 THEN Send '\aB'     /* Tell BB to abort ARexx */
  87.           IF chances=6 THEN                /* time to die */
  88.             DO
  89.               SAY 'BBBBS_Demon calling reboot in 20 seconds...'
  90.               Send '\rBBBBS_Demon calling reboot in 20 seconds...\r'
  91.               chances=1
  92.               bbspath=GETCLIP('BBS_path')
  93.               IF bbspath~='' THEN
  94.                 ADDRESS COMMAND 'date >'bbspath'Numbers/LastDemonBoot'
  95.               IF EXISTS(bbspath'Sounds/Alert') THEN
  96.                 ADDRESS COMMAND 'c:sound' bbspath'Sounds/Alert 5'
  97.               IF EXISTS('c:boot') THEN
  98.                 DO
  99.                   CALL DELAY(250)
  100.                   ADDRESS COMMAND boot
  101.                 END
  102.             END
  103.         END
  104.       ELSE chances=1
  105.     END
  106. END
  107. EXIT
  108.  
  109. /* BBBBSdemon.baud */
  110.